package com.gemme.gemme.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gemme.gemme.R;
import com.gemme.gemme.util.DpUtil;
import com.gemme.gemme.util.ShapeUtil;

public class GuigeTextView extends RelativeLayout {
    private Context context;
    boolean isSelect = false;
    public GuigeTextView(Context context) {
        this(context,null);
    }

    public GuigeTextView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public GuigeTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }
    TextView tv;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.guige_textview,this);

        tv = findViewById(R.id.tv);
        changestate();

       /* tv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                isSelect = !isSelect;
                setState();
            }
        });*/
    }

    private void changestate() {
        if(isSelect){
            tv.setTextColor(Color.parseColor("#fff9f9f9"));
//            tv.
            tv.setBackground(ShapeUtil.getCornBg(DpUtil.dip2px(context,2),"#FF9D2C2F"));
        }else{
            tv.setTextColor(Color.parseColor("#ffcccccc"));
//            tv.
            tv.setBackground(ShapeUtil.setCornBgStrok(DpUtil.dip2px(context,2),"#FFF9F9F9",
                    DpUtil.dip2px(context,1),"#ffe8e8e8"));
        }
    }

    public void setIsSelect(boolean isSelect){
        this.isSelect = isSelect;
        changestate();
    }

    public boolean getIsSelect(){
        return isSelect;
    }
    public GuigeTextView setContent(String content){
        tv.setText(content + "");
        return this;
    }



}
